package com.jh.microservice.reactive;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
public class WebFluxDemo {

    @RequestMapping("")
    public Mono<String> helloWorld() {
        print("准备处理");
        Mono<String> result = Mono.fromSupplier(() -> {
            print("开始处理数据");
            return "Hello World";
        });
        return result;
    }

    public static void print(String message) {
        System.out.printf("【线程：%s】：%s\n", Thread.currentThread().getName(), message);
    }
}
